﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using GS.DataConnection;

namespace GS.CMS.Entities
{
    public class Products
    {
        #region Declare Variables
        byte _StatusProductID;
        int _ProductsID, _Qty_Order;
        string _ImageURL, _Name, _CategoryID, _Content, _Support;
        public bool _IsActive;
        decimal _Price;
        DateTime _CreatedDate, _UpdatedDate;
        #endregion
        #region properties
        public int Qty_Order
        {
            get { return _Qty_Order; }
            set { _Qty_Order = value; }
        }
        public byte StatusProductID
        {
            get { return _StatusProductID; }
            set { _StatusProductID = value; }
        }
        public int ProductID
        {
            get { return _ProductsID; }
            set { _ProductsID = value; }
        }
        public string ImageURL
        {
            get { return _ImageURL; }
            set { _ImageURL = value; }
        }
        public DateTime CreatedDate
        {
            get { return _CreatedDate; }
            set { _CreatedDate = value; }
        }
        public DateTime UpdatedDate
        {
            get { return _UpdatedDate; }
            set { _UpdatedDate = value; }
        }

        public bool IsActive
        {
            get { return _IsActive; }
            set { _IsActive = value; }
        }
       
        public string Content
        {
            get { return _Content; }
            set { _Content = value; }
        }
        public decimal Price
        {
            get { return _Price; }
            set { _Price = value; }
        }
        #endregion
        #region public method
        public DataSet GetListStatusProducts(string Status, int pgNum)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@strStatus", Status);
            ht.Add("@pgNum", pgNum);
            return SqlProvider.GetDataSet("pro_products_status",ht);
        }
        public DataSet GetListProducts(int pgNum)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@pgNum", pgNum);
            return SqlProvider.GetDataSet("pro_products_list", ht);
        }
        public DataSet GetListUpcomingAndNewProducts()
        {
            return SqlProvider.GetDataSet("pro_products_upcoming_new");
        }
        public DataSet GetListProducts()
        {
            return SqlProvider.GetDataSet("pro_products_get_all");
        }
        public DataTable GetProductByIDCart(int ProductID)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@ProductID", ProductID);
            return SqlProvider.GetTable("pro_products_get_by_id_cart","dtProduct", ht);
        }
        public DataTable GetAllProductInfo()
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            return SqlProvider.GetTable("pro_productinfo_get_all", "dtInfo", ht);
        }
        public DataTable GetProductInfoByID(int ProductID)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@ProductID", ProductID);
            return SqlProvider.GetTable("w_productinfo_sel_id", "dtInfo", ht);
        }
        public DataSet GetAllFunction()
        {
            return SqlProvider.GetDataSet("w_get_all_function", "dsFuntion");
        }
        public DataSet SearchProducts(int pgNum, string KeySearch, decimal PriceFrm, decimal PriceTo)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@pgNum", pgNum);
            ht.Add("@n_KeySearch", KeySearch);
            ht.Add("@PriceFrom", PriceFrm);
            ht.Add("@PriceTo", PriceTo);
            return SqlProvider.GetDataSet("w_productinfo_search", ht);
        }
        public DataSet SearchProductsAdmin(int pgNum, string KeySearch)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@pgNum", pgNum);
            ht.Add("@n_KeySearch", KeySearch);
            return SqlProvider.GetDataSet("w_productinfo_search_admin", ht);
        }

        public DataTable GetProductByIndexID()
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            return SqlProvider.GetTable("w_produtcindex_get_by_id", "dtLogo", ht);
        }
        public DataTable GetLogoByID()
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            return SqlProvider.GetTable("w_produtcindex_get_by_id", "dtLogo", ht);
        }
        public DataSet GetProductByID(int ProductID)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@ProductID", ProductID);
            return SqlProvider.GetDataSet("pro_products_get_by_id", ht);
        }
        public DataTable GetImagesByProductID()
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@ProductID", ProductID);
            return SqlProvider.GetTable("w_imagesProduct_sel_id", "dtImage", ht);
        }
        public DataTable GetImagesByImageID(int ImageID)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@ImageID", ImageID);
            return SqlProvider.GetTable("w_productimage_sel_id", "dtImageInfo", ht);
        }
        public DataSet GetProductByIDAdmin()
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@ProductID", ProductID);
            return SqlProvider.GetDataSet("w_products_sel_id_admin", ht);
        }
        public DataTable GetPromotionByID()
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@ProductID", ProductID);
            return SqlProvider.GetTable("w_promotion_sel_id", "dtPromotion", ht);
        }
        public DataSet GetNicePicByID(string Type)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@Type", Type);
            return SqlProvider.GetDataSet("w_nicepic_sel_id", ht);
        }
        public int ProductUpdate()
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@ProductID", ProductID);
            ht.Add("@ImageURL", ImageURL);
            ht.Add("@Price", Price);
            ht.Add("@StatusProductID", StatusProductID);
            ht.Add("@n_Content", Content);
            ht.Add("@Qty_Order", Qty_Order);
            return int.Parse(SqlProvider.ExecuteScalar("w_products_update", ht).ToString());
        }
        public int ImageUpdate(int ImageID)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@ProductID", ProductID);
            ht.Add("@ImgPath", ImageURL);
            ht.Add("@ImageID", ImageID);
            return int.Parse(SqlProvider.ExecuteScalar("w_imageproduct_update", ht).ToString());
        }
        public int PromotionUpdate(decimal PriceDown)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@ProductID", ProductID);
            ht.Add("@n_Content", Content);
            ht.Add("@PriceDown", PriceDown);
            return int.Parse(SqlProvider.ExecuteScalar("w_promotion_update", ht).ToString());
        }
        public int CurrnecyUpdate(decimal CurrencyVND, string Pass)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@CurrencyVND", CurrencyVND);
            ht.Add("@Pass", Pass);
            return int.Parse(SqlProvider.ExecuteScalar("w_currency_update", ht).ToString());
        }
        //public int ProductInfoUpdate()
        //{
        //    System.Collections.Hashtable ht = new System.Collections.Hashtable();
        //    ht.Add("@ProductID", ProductID);
        //    ht.Add("@n_CPU", _CPU);
        //    ht.Add("@n_Ram", _Ram);
        //    ht.Add("@n_Hdd", _Hdd);
        //    ht.Add("@n_Vga", _Vga);
        //    ht.Add("@n_Optical", _Optical);
        //    ht.Add("@n_OS", _OS);
        //    ht.Add("@n_CardReader", _CardReader);
        //    ht.Add("@n_Battery", _Battery);
        //    ht.Add("@n_Wireless", _Wireless);
        //    ht.Add("@n_Color", _Color);
        //    ht.Add("@n_Webcam", _Webcam);
        //    ht.Add("@n_Display", _Display);
        //    ht.Add("@n_More", _More);
        //    ht.Add("@n_Lan", _Lan);
        //    ht.Add("@n_MainBoard", _MainBoard);
        //    return int.Parse(SqlProvider.ExecuteScalar("w_productinfo_update", ht).ToString());
        //}

        public int DeleteProducts(string _SelectedIDs)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@SelectedIDs", _SelectedIDs);
            return int.Parse(SqlProvider.ExecuteScalar("w_products_remove_by_ids", ht).ToString());
        }
        public DataTable GetImageProductDel(string _SelectedIDs)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@SelectedIDs", _SelectedIDs);
            return SqlProvider.GetTable("w_products_list_by_ids", "dtProductdel", ht);
        }

        public int DeleteNicePic(int _SelectedIDs)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@SelectedIDs", _SelectedIDs);
            return SqlProvider.ExecuteSQL("w_nicepic_del_by_ids", ht);
        }
        public int ProductActivate(string SelectedIDs)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@SelectedIDs", SelectedIDs);
            return SqlProvider.ExecuteSQL("w_products_activate", ht);
        }
        public int ProductDeActivate(string SelectedIDs)
        {
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("@SelectedIDs", SelectedIDs);
            return SqlProvider.ExecuteSQL("w_products_deactivate", ht);
        }

        #endregion
    }
}
